package no.ntnu.fp.server;

import java.sql.Connection;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public final class ConnectionProvider {
	
	private final static Lock connectionLock = new ReentrantLock(true);
	private static Connection connection;
	
	public static void relinquishConnection() {
		connectionLock.unlock();
	}
	public static Connection requestConnection() {
		connectionLock.lock();
		return connection;
	}
	
	public static void initialize(Connection connection) {
		ConnectionProvider.connection = connection;
	}
	
	private ConnectionProvider() { }
}
